import 'package:kongqi/global.dart';
import 'package:kongqi/http/api.dart';
import 'package:flutter/material.dart';

class PM25DetailPage extends StatefulWidget {
  PM25DetailPage({Key key, this.id}) : super(key: key);
  final String id;
  @override
  _PM25DetailPageState createState() => _PM25DetailPageState();
}

class _PM25DetailPageState extends State<PM25DetailPage> {
  var _data;
  @override
  void initState() {
    String _id = widget.id;
    getPM25Detail(_id).then((res) {
      setState(() {
        _data = res;
      });
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return _data == null
        ? Scaffold(
            body: Container(
              width: MediaQuery.of(context).size.width,
              height: MediaQuery.of(context).size.height,
              color: Global.backgroundColor,
              child: Center(child: CircularProgressIndicator()),
            ),
          )
        : Scaffold(
            appBar: AppBar(
              title: Text(_data['title'], style: TextStyle(fontSize: 14)),
              elevation: 0,
              backgroundColor: Global.primaryColor,
            ),
            body: Container(
              width: MediaQuery.of(context).size.width,
              height: MediaQuery.of(context).size.height,
              child: SingleChildScrollView(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    Container(
                      padding: EdgeInsets.all(15),
                      child: Text(
                        "${_data['content']}",
                        style: TextStyle(
                          color: Global.fontColor,
                          fontSize: 14,
                          fontWeight: FontWeight.w400,
                          height: 2.1,
                        ),
                      ),
                    ),
                    SizedBox(height: 35),
                  ],
                ),
              ),
            ),
          );
  }
}
